
#include <BLayout>
#include "member_BLayout.h"
#include "member_BWidget.h"

using namespace BWE;

#define member					(*(member_BLayout*)_ptr)
#define member_allocate()		_ptr = new member_BLayout(this)
#define member_release()		delete (member_BLayout*)_ptr

BLayout::BLayout()
{
	member_allocate();
}
BLayout::~BLayout()
{
	member_release();
}

void BLayout::setHost(BWidget* host)
{
	member.host = host;
}
BWidget* BLayout::host() const
{
	return member.host;
}

void BLayout::setRect(const BRect& rect)
{
	if (member.rect != rect)
	{
		member.rect = rect;
		member.dirty = true;
	}
}
const BRect& BLayout::rect() const
{
	return member.rect;
}

void BLayout::setBorder(int border)
{
	if (member.border != border)
	{
		member.border = border;
		this->dirty();
	}
}
int BLayout::border() const
{
	return member.border;
}

void BLayout::setSpace(int space)
{
	if (member.space != space)
	{
		member.space = space;
	}
}
int BLayout::space() const
{
	return member.space;
}

void BLayout::setSizeStretch(const BSizeStretch& sizeStretch)
{
	if (member.sizeStretch != sizeStretch)
	{
		member.sizeStretch = sizeStretch;
		this->dirty();
	}
}
BSizeStretch BLayout::sizeStretch() const
{
	return member.sizeStretch;
}

void BLayout::setSizePolicy(const BSizePolicy& sizePolicy)
{
	if (member.sizePolicy != sizePolicy)
	{
		member.sizePolicy = sizePolicy;
		member.dirty = true;
		this->dirty();
	}
}

void BLayout::setMinSize(const BSize& minSize)
{
	if (member.minSize != minSize)
	{
		member.minSize = minSize;
		this->dirty();
	}
}
BSize BLayout::minSize() const
{
	return member.minSize;
}

void BLayout::setMaxSize(const BSize& maxSize)
{
	if (member.maxSize != maxSize)
	{
		member.maxSize = maxSize;
		this->dirty();
	}
}
BSize BLayout::maxSize() const
{
	return member.maxSize;
}

void BLayout::dirty() const
{
	member.dirty = true;
	if (member.host)
	{
		member.host->fresh();
	}
}
bool BLayout::isdirty() const
{
	return member.dirty;
}
void BLayout::clean() const
{
	member.dirty = false;
}
